Field of the Invention
Embodiments of the present invention relate generally to graphics processing and, more specifically, to rendering cover geometry without internal edges.
Description of the Related Art
Path rendering is a style of resolution-independent 2-dimensional rendering, often called “vector graphics,” that is the basis for a number of important rendering standards. Those standards include Postscript, Java 2D, Apple's Quartz 2D, OpenVG, PDF, TrueType fonts, OpenType fonts, PostScript fonts, HTML 5 Canvas, Scalable Vector Graphics (SVG) web format, Microsoft's Silverlight and Adobe Flash. for interactive web experiences, Microsoft's XML Specification (XPS), drawings in Office file formats including PowerPoint, Adobe Illustrator illustrations, and more.
In path rendering, a software application typically specifies a scene as a sequence of resolution-independent outlines, known as paths, that may be painted with constant colors, linear or radial gradients, or images. Many graphics processing units (GPUs) support rendering such paths through a two-pass rendering process known as “stencil-then-cover.” First, in a path stenciling pass, the GPU generates a stencil buffer that indicates which samples (i.e., locations within each pixel) are covered by the path. Second, in a path covering pass, the GPU generates cover geometry for the path and shades the cover geometry with stencil testing enabled. Typically, the GPU implements the cover geometry with some sort of conservative bounding geometry, such as a bounding box (i.e., two triangles), a convex hull, or a similar construct. Because stencil testing is enabled during the path covering pass, the GPU discards any fragments that are not covered by the path and writes the surviving fragments to the color buffer as processed graphics data.
In some approaches to stencil-then-cover path rendering, the GPU maintains N coverage samples per pixel and M color samples per pixel, where N is greater than M. In operation, the GPU determines the coverage of the path at N coverage samples per pixel. Then, during the path covering pass, before the GPU performs blending and color write operations, the GPU reduces the number of coverage samples to the number of color samples. Notably, during this reduction operation, the GPU may select a group of N/M coverage samples associated with a single color sample and generate an opacity value for the color sample based on the proportion of the N/M coverage samples that are covered.
One limitation of this rendering approach is that internal edges in the cover geometry may introduce conflation artifacts. Such conflation artifacts are caused by conflating coverage with opacity when reducing the multiple coverage samples to the single color sample. In particular, the reduction conflates a Boolean concept with a fractional value. For example, suppose that there were 4 coverage samples corresponding to each color sample (N=4 and M=1), the background color were red, and the cover geometry were to include two triangles with a single diagonal shared edge. Further, suppose that two of the coverage samples associated with a particular color sample were covered by the first triangle, and two of the coverage samples associated with the particular color sample were covered by the second triangle. Upon rendering the first triangle, the GPU would assign an intermediate red-blue color to the particular color sample—a blend of 50% of the blue color associated with the first triangle and 50% of the red color associated with the background. Subsequently, upon rendering the second triangle, the GPU would assign a different shade of red-blue color to the particular color sample—a blend of 50% of the blue color associated with the second triangle and 50% of the intermediate red-blue color. Such background color bleeding would degrade the quality of the displayed image. In particular, a fraction of the red background color would be visible at the diagonal edge shared between the two triangles covering the path (as if they were not fully covered by the path.)
In one approach to reducing the conflation artifacts associated with the cover geometry, the number of color samples is increased to match the number of coverage samples. In such implementations, the coverage is maintained separately for each color sample as a Boolean value and is not conflated with opacity. Consequently, rendering cover geometry that includes internal edges does not introduce conflation artifacts. However, increasing the number of color samples increases both the memory consumption and the memory bandwidth used by the color buffer. Because both the local memory capacity of GPUs and the associated memory bandwidth is limited, any increase in either memory consumption or memory bandwidth use is generally undesirable.
Accordingly, what is needed in the art is a more effective approach to rendering cover geometry.